<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>代理用户详情</title>
		<meta name="renderer" content="webkit">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport"
			content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
		<link rel="stylesheet" href="/resource/layuiadmin/layui/css/layui.css" media="all">
		<link rel="stylesheet" href="/resource/css/mylay.css">
		<link rel="stylesheet" href="./layui/layui/css/layui.css">
		<link rel="stylesheet" href="/resource/css/kpi_list.css">
		</link>
	</head>

	<body>
		<div class="all">
			<!-- 表单元素 -->
			<div class="layui-tab">
				<div class="layui-tab-content">
					<div class="layui-tab-item layui-show DaiLiYongHu">
						<div style="padding: 20px; background-color: #F2F2F2;">
							<div class="layui-row layui-col-space15">
								<div class="layui-col-md12">
									<div class="layui-card" style="padding: 10px;">
										<form class="layui-form search">
											<div class="layui-form-item">
												<div class="layui-inline">
													<label class="layui-form-label">账号</label>
													<div class="layui-input-inline">
														<input class="layui-input" name="account" autocomplete="off">
													</div>
												</div>
												<div class="layui-inline">
													<label class="layui-form-label">代理商名称</label>
													<div class="layui-input-inline">
														<input class="layui-input" name="username" autocomplete="off">
													</div>
												</div>
												<div class="layui-inline">
													<label class="layui-form-label">注册时间</label>
													<div class="layui-input-inline">
														<input class="layui-input" id="datetimeRange"
															name="datetimeRange" autocomplete="off">
													</div>
												</div>
												<div class="layui-form-mid" id="user">状态</div>
												<div class="layui-input-inline" style="width: 100px;">
													<select name="state" lay-verify="" id="selete">
														<option value="0">全部</option>
														<option value="1">启用</option>
														<option value="2">停用</option>

													</select>
												</div>
												<div class="layui-inline" style="text-align: center;">
													<button type="button" class="layui-btn" id="layui-btn1"
														data-type="search">搜索</button>
												</div>
											</div>
										</form>
									</div>
								</div>
							</div>
						</div>
						<table id="DaiLiYongHu" lay-filter="DaiLiYongHu"></table>
						<script type="text/html" id="barDemo">{{d.username}}
						<a href="/manage/Useragent/agentUsersDetail?id={{d.id}}" class="layui-table-link">详情</a>
						</script>
					</div>
				</div>
			</div>
		</div>
		<script src="/resource/layuiadmin/layui/layui.js"></script>
		<script src="/resource/js/manage/init_date.js"></script>
		<script src="/manage/user.js"></script>
		<script src="./layui/layui/layui.js"></script>
		<script>
			//注意：选项卡 依赖 element 模块，否则无法进行功能性操作
			layui.use(['element', 'table', 'form'], function() {
				var form = layui.form;
				var element = layui.element;
				var $ = layui.$;
				var table = layui.table;
				var laydate = layui.laydate;
				laydate.render({
					elem: '#datetimeRange',
					type: 'datetime',
					range: true
				});

				//-----------------------个人
				table.render({
					elem: '#DaiLiYongHu',
					title: "代理商列表",
					url: '/manage/useragent/agentUsers',
					method: 'get',
					cols: [
						[
							//表头
							{
								field: 'username',
								title: '代理商账户',
								toolbar: '#barDemo',
							},
							{
								field: 'nickname',
								title: '名称'
							},
							{
								field: 'userTotal',
								title: '当前下级用户数'
							},
							{
								field: 'total_recharge',
								title: '充值总额'
							},
							{
								field: 'total_withdrawals',
								title: '提现总额'
							},
							{
								field: 'balance',
								title: '当前用户余额'
							},
							{
								field: 'total_tasks',
								title: '任务数'
							},
							{
								field: 'total_task_amount',
								title: '任务总额'
							},
							{
								field: 'user_person_reward',
								title: '用户业绩奖励总额'
							},
							{
								field: 'reward_value',
								title: '团队业绩奖励总额'
							},
							{
								field: 'level_reward',
								title: '级差奖励总额'
							}
						]
					],
					cellMinWidth: 100,
					toolbar: '#toolbarDemo',
					defaultToobar: ["filter", 'print', 'exports'],
					totalRow: true,
					page: {
						layout: ['count', 'prev', 'page', 'next', 'limit', 'refresh', 'skip']
					},
					skin: 'row' //行边框风格
						,
					even: true //开启隔行背景

				});
				active1 = {
					search: function() {
						console.log('搜索')
						//执行重载
						table.reload('DaiLiYongHu', {
							page: {
								curr: 1 //重新从第 1 页开始
							},
							where: {
								username: $("input[name='username']").val(),
								account: $("input[name='account']").val(),
								state: $("select[name='state'] option:selected").val(),
								datetime_range: $("input[name='datetimeRange']").val(),
							}
						}, 'data');
					}
				};

				$('.DaiLiYongHu #layui-btn1').on('click', function() {
					var type = $(this).data('type');
					active1[type] ? active1[type].call(this) : '';
				});
			});
		</script>
	</body>
</html>
